From 30860b6fe5224c7922ed20adff4929547431ede1 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 2 Apr 2008 15:32:13 +0100 Subject: [PATCH] minios: Fix xfree() bug. It has to check first if the memory to free is so big as to be freed directly by free_pages. mini-os domains crash without this patch if vfb is misconfigured. Signed-off-by: INAKOSHI Hiroya --- extras/mini-os/lib/xmalloc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extras/mini-os/lib/xmalloc.c b/extras/mini-os/lib/xmalloc.c index d4c3941738..82d5cc61db 100644 --- a/extras/mini-os/lib/xmalloc.c +++ b/extras/mini-os/lib/xmalloc.c @@ -208,6 +208,13 @@ void xfree(const void *p) pad = (struct xmalloc_pad *)p - 1; hdr = (struct xmalloc_hdr *)((char *)p - pad->hdr_size); + /* Big allocs free directly. */ + if ( hdr->size >= PAGE_SIZE ) + { + free_pages(hdr, get_order(hdr->size)); + return; + } + /* We know hdr will be on same page. */ if(((long)p & PAGE_MASK) != ((long)hdr & PAGE_MASK)) { @@ -222,13 +229,6 @@ void xfree(const void *p) *(int*)0=0; } - /* Big allocs free directly. */ - if ( hdr->size >= PAGE_SIZE ) - { - free_pages(hdr, get_order(hdr->size)); - return; - } - /* Merge with other free block, or put in list. */ /* spin_lock_irqsave(&freelist_lock, flags); */ list_for_each_entry_safe( i, tmp, &freelist, freelist ) -- 2.30.2